$(document).ready(function(){
	var inputRecordID = "";
	var inputRxList = "";
	var inputDoctorID = "";
	var msg = "";
	$("#dialog-confirm").dialog({
		autoOpen: false,
		title:'Confirm sending prescription',
		draggable: true,
		resizable: true,
		height: 360,
		modal: true,
		show: "fade",
		hide: "fade",
		open: function(){
			$("#dialog-confirm").html(msg);
		},
		buttons: {
			Confirm: function(){
				//stop form from submitting normally
				event.preventDefault();
				//get some values from elements on the page
				var $form = $("#PrescriptionForm");
				var url = "http://158.108.38.86:8080/DotC/HangoutRequest";
				//Send the data using post and put the results in a div
				$.post(url,
					{
						RecordID : inputRecordID,
						RxList : inputRxList,
						DoctorID : inputDoctorID
					},
					function(){
						$("#result").html('Finish!');
					}
				);
				alert('Your prescription is sent');
				$(this).dialog("close");
			},
			Cancel: function(){
				$(this).dialog("close");
			}
		}
	});

	$("#btn-submit").button().click(function() {
		inputRecordID = $('#RecordID').val();
		inputRxList = $('textarea#Rx').val();
		inputDoctorID = $('#DoctorID').val();
		msg = "Your prescription is:<br>Record ID =" + inputRecordID + "<br>Rx List = " + inputRxList + "<br>Doctor ID = " + inputDoctorID;
		$("#dialog-confirm").dialog('open');
		//$("#dialog-confirm").dialog('destroy');
	});
});